/*
 * 宠物
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package function;

import engine.goods.Goods;
import java.util.Hashtable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import mainpackage.Constant;
import mainpackage.GameBean;
import mainpackage.InputInterFace;
import mainpackage.MainCanvas;
import mainpackage.MainGame;
import mainpackage.MainLogic;
import mainpackage.MainView;
import mainpackage.ResManager;
import mainpackage.Tools;
import ui.UiInterFace;

/**
 *
 * @author foonwayx
 */
public class Pet {

    private Image[] imgArray;
    private String[] sArray;
    public int[] iArray;
    private int iPositionY = 0;
    private boolean bUiKeyPressLock;
    private byte byPopUpState = -1; //记录界面弹出层的UI状态变化
    private byte byState = 0; //记录在跟新页面状态的时候的小状态
    public byte bySelectIndex = 1;
    public Goods items;
    public short[] shPetState;  //宠物属性数字
    public int[] iAvatarID;
    public String[] sOpArray;
    public short shHeight = 0;
    public byte byUiState = 0;
    public int startX = 0;
    public int startY = 0;
    public byte byItemSelectIndex = -1;
    public byte bySubSelectIndex = 1;
    public byte byMenuIndex = 0;
    public boolean bLock;
    public boolean bLockChangePetAlias;
    private boolean bFlag;
    private boolean bSetPetIndex;
    public byte byPetOperation;
    private boolean bShowOtherPlayerPet;
    public long lOtherPlayerID = -1;
    public String sOtherPlayerNick;
    private int iStartPointY;
    private String sItemTips;
    private short shTipsW;
    private short shTipsH;

    /**
     * 打开宠物装备栏
     */
    public void openPetEquip(boolean bShowOtherPlayerPet) {
        this.bShowOtherPlayerPet = bShowOtherPlayerPet;
        if (MainLogic.getInstance().byGameState == Constant.GAME_UI_PET_EQUIP) {
            MainLogic.getInstance().pushState(Constant.GAME_UI_PET_EQUIP, true);
        } else {
            this.byItemSelectIndex = 1;
            if (!bSetPetIndex) {
                this.bySubSelectIndex = 1;
            }
            this.bySelectIndex = 1;
            MainLogic.getInstance().pushState(Constant.GAME_UI_PET_EQUIP, true);
        }
    }

    /**
     * 根据宠物 的id锁定到第几个宠物
     * @param lPetID 
     */
    public void lockPet(long lPetID) {
        short max = this.items.getMaxColumNum();
        for (short i = 0; i < max; i++) {
            if (this.items.checkColumnHasGoods(i) && this.items.lColumnKey[i] == lPetID) {
                this.byItemSelectIndex = (byte) (i + 1);
                this.bySubSelectIndex = 1;
                this.bySelectIndex = 1;
                this.setRollText();
                this.setPetString((byte) i);
                break;
            }
        }
    }

    public void getOtherPlayerPetEquip(long lOtherPlayerID, String lOtherPlayerNick) {
        this.lOtherPlayerID = lOtherPlayerID;
        this.sOtherPlayerNick = lOtherPlayerNick;
        GameBean.L_PLAYER_ID = lOtherPlayerID;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    /*********************************宠物装备界面*********v*********************************************/
    //卸载宠物
    public void delPetEquip(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物卸载失败!");
                break;
            case 1:
                if (this.byItemSelectIndex <= this.items.getMaxColumNum() && this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                    this.items.deleteGoods((short) (this.byItemSelectIndex - 1));
                    this.removeSkillHash((byte) (this.byItemSelectIndex - 1), (byte) (this.iArray[(this.byItemSelectIndex - 1) * 14 + 13]), (byte) -1);
                }
                this.setPetString((byte) (this.byItemSelectIndex - 1));
                this.setRollText();
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物卸载成功!");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的宠物背包已满了，请先清理!");
                break;
        }
    }

    /**
     * 宠物喂养
     * @param stateCode
     * @param lPetKey
     * @param shPetBodyPower
     * @param shLoyalty
     */
    public void petFeed(byte stateCode, long lPetKey, byte byHappyDegree) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物喂养失败");
                break;
            case 1:
                this.iArray[14 * (this.byItemSelectIndex - 1) + 6] = byHappyDegree;
                if (MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.getInstance().uiPackage.shPos) > 1) {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().shStackNum[MainLogic.getInstance().uiPackage.shPos] -= 1;
                } else {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                }
                //快乐度
                this.setPetString((byte) (this.byItemSelectIndex - 1));
                if (this.iArray[14 * (this.byItemSelectIndex - 1) + 3] == 1) {
                    MainLogic.getInstance().gamePlayer.byPetHappyDegree = byHappyDegree;
                    MainLogic.getInstance().gamePlayer.setPetTalk();
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物喂养成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择正确的宠物食品喂养宠物");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物已经很饱了，不用再喂养啦！");
                break;
            case 4:
                Tools.printLog("接受到宠物快乐度得改=" + byHappyDegree);//漫游界面下
                if (byHappyDegree <= 20) {
                    MainLogic.getInstance().gamePlayer.deletePetsAni();
                } else {
                    MainLogic.getInstance().gamePlayer.byPetHappyDegree = byHappyDegree;
                    MainLogic.getInstance().gamePlayer.setPetTalk();
                }
                break;
        }


    }
    /**
     * 初始化宠物装备栏界面的资源
     */
    public Hashtable sHashtable;

    public void setPetString(byte pos) {
        if (this.items.checkColumnHasGoods(pos)) {
            this.shHeight = (short) Tools.getParagraphHeight(this.items.getGoodsDesc(pos), 209, 16);
            byte byPos = (byte) (pos * 14);
            this.sArray[5] = "<l" + this.items.getGoodsAlias(pos) + '>';
            this.sArray[5] = "  " + this.items.getGoodsLevel(pos) + " ";
            this.sArray[5] += (this.iArray[byPos + 3] == 1) ? "  守护中" : "  休息中";
            //快乐度
            if (this.iArray[byPos + 6] >= 91 && this.iArray[byPos + 6] <= 100) {
                this.sArray[5] += "  兴奋 " + this.iArray[byPos + 6];
            } else if (this.iArray[byPos + 6] >= 61 && this.iArray[byPos + 6] <= 90) {
                this.sArray[5] += "  快乐 " + this.iArray[byPos + 6];
            } else if (this.iArray[byPos + 6] >= 41 && this.iArray[byPos + 6] <= 60) {
                this.sArray[5] += "  正常 " + this.iArray[byPos + 6];
            } else if (this.iArray[byPos + 6] >= 21 && this.iArray[byPos + 6] <= 40) {
                this.sArray[5] += "  不满 " + this.iArray[byPos + 6];
            } else if (this.iArray[byPos + 6] >= 0 && this.iArray[byPos + 6] <= 20) {
                this.sArray[5] += "  愤怒 " + this.iArray[byPos + 6];
            }
            this.sArray[6] = "智:" + this.iArray[byPos + 9] + "  精:" + this.iArray[byPos + 10] + "  力:" + this.iArray[byPos + 11];
            this.sArray[7] = "敏:" + this.iArray[byPos + 12] + "      潜能:" + this.iArray[byPos + 7] + " / " + this.iArray[byPos + 8];
            this.sArray[8] = "资质:";
            switch (this.iArray[byPos + 1]) {
                case 0:
                    this.sArray[8] += "平凡 ";
                    break;
                case 1:
                    this.sArray[8] += "优秀 ";
                    break;
                case 2:
                    this.sArray[8] += "杰出 ";
                    break;
                case 3:
                    this.sArray[8] += "完美 ";
                    break;
            }
            this.sArray[9] = "经验：" + this.iArray[byPos + 4] + " / " + this.iArray[byPos + 5];
        } else {
            this.sArray[5] = "<l宠物名称>";
            this.sArray[6] = "智：0  " + "  精：0" + "  力：0";
            this.sArray[7] = "敏：0  " + "  潜能： " + 0 + " / " + 0;
            this.sArray[8] = "资质：";
            this.sArray[9] = "经验：" + 0 + " / " + 0;
        }
        this.sArray[0] = !this.bShowOtherPlayerPet ? "我的宠物" : sOtherPlayerNick + "的宠物";
        if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
            this.sArray[0] = (!this.bShowOtherPlayerPet ? "我的宠物" : sOtherPlayerNick + "的宠物") + " - " + this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1));
        }
    }

    public void initPetEquip() {
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[11];
             this.imgArray[0] = ResManager.createImage(90000041); //小箭头图片
             this.imgArray[1] = Tools.makeBlueMask(); //蓝色选择条
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255); //边框图片
             this.imgArray[4] = ResManager.createImage(90000086);//蓝条
             this.imgArray[5] = ResManager.createImage(90000043);  //文字图片
             this.imgArray[6] = ResManager.createImage(90000085);//确认按钮图片
             this.imgArray[7] = ResManager.createImage(90000049); //星星图片
             this.imgArray[8] = ResManager.createImage(90000084);//方向键图片
             this.imgArray[9] = ResManager.createImage(90000034);//技能锁
             this.imgArray[10] = ResManager.createImage(90000044); //文字图片
            //#else
//#            this.imgArray = new Image[10];
//#            //箭头图片
//#            this.imgArray[0] = ResManager.createImage(90000041);
//#            //蓝色光片
//#            this.imgArray[1] = Tools.makeBlueMask();
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            //背景图片
//#            this.imgArray[2] = ResManager.createImage(90000017);
            //#endif
//#
//#            //边框图片
//#            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            //文字图片
//#            this.imgArray[5] = ResManager.createImage(90000043);
//#            //星星图片
//#            this.imgArray[7] = ResManager.createImage(90000049);
//#            //技能描述背景
//#            this.imgArray[8] = Tools.makeTransparent(10, 57, 120, 0x000000);
//#            //技能锁定图片
//#            this.imgArray[9] = ResManager.createImage(90000034);
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //#if NOKIA_E72
//#         Tools.initE72ScollBar();
        //#endif

        /**测试*/
//        sHashtable = new Hashtable();//(1,技能的文字描述,2:技能的图片iD,3:技能的锁定情况)
//        this.items = new Goods();
//        this.items.init((short) 1, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.iArray = new int[]{1, 3, 4, 1, 23333, 222222, 100, 150, 150, 9999, 9999, 9999, 9999, 2};
//        byItemSelectIndex = 1;
//        this.bySelectIndex = 1;
        /*8end*/
        this.sArray = new String[]{!this.bShowOtherPlayerPet ? "我的宠物" : sOtherPlayerNick + "的宠物", "草食", "肉食", "杂食", "宠物改名", "", "", "", "", "", "确定", "返回"};
        //成长率,当前潜能，总的潜能
        //this.iArray = new int[78];
        //0:宠物类型型(食草，食肉，杂食)
        //1:资质(0:平凡,2:优秀,1:杰出,3,完美)
        //2:成长(0-4:1星-5星)
        //3:当前宠物状态
        //4:当前经验值
        //5:最大经验值
        //6:快乐度
        //7:当前潜能
        //8:最大潜能
        //9:智力
        //10:精力
        //11:力量
        //12:灵敏
        //13宠物槽数量

//        this.byUiState = 1;
//        GameBean.STR_CMD_GOODS_NAME = "天气非常低";\
        this.setRollText();
        this.setPetString((byte) (this.byItemSelectIndex - 1));
        bSetPetIndex = false;
    }

    /**
     * 绘制宠物装备栏的界面
     * @param g
     */
    public void drawPetEquip(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[8], this.imgArray[6], this.imgArray[4], this.imgArray[5], this.sArray[0]);
         //绘制已经装备的宠物
         for (byte i = 0; i < 6; i++) {
             this.items.drawGoods(g, Constant.UI_START_X + 33 + 50 * i, Constant.UI_START_Y + 49, i, false, false);
             if (i == this.byItemSelectIndex - 1) {
                 items.drawSelectStyle(g, Constant.UI_START_X + 33 + 50 * i, Constant.UI_START_Y + 49);
                 //名称
                 Tools.drawParagraph(g, Constant.UI_START_X + 33, Constant.UI_START_Y + 110, 330, this.sArray[5], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT + 4, 0x000000);
                 //潜能
                 Tools.drawShadowString(g, (byte) 1, this.sArray[6], Constant.UI_START_X + 33, Constant.UI_START_Y + 110 + Constant.FONT_SMALL_HEIGHT + 4, 0xFFFFFF, 0x000000);
                 //名称
                 Tools.drawShadowString(g, (byte) 1, this.sArray[7], Constant.UI_START_X + 33, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4 << 1), 0xFFFFFF, 0x000000);
                 //潜能
                 Tools.drawShadowString(g, (byte) 1, this.sArray[8], Constant.UI_START_X + 33, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4) * 3, 0xFFFFFF, 0x000000);
                 //名称
                 Tools.drawShadowString(g, (byte) 1, this.sArray[9], Constant.UI_START_X + 33, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4 << 2), 0xFFFFFF, 0x000000);
                 if (this.items.checkColumnHasGoods(i)) {
                     //成长率图片
                     for (byte j = 0; j <= this.iArray[i * 14 + 2]; j++) {
                         g.drawImage(this.imgArray[7], Constant.UI_START_X + 33 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + j * 14, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4) * 3, 0);
                     }
                     //类型
                     switch (this.iArray[i * 14]) {
                         case 0:
                             Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + 35 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4) * 3, 0x00FF00, 0x000000);
                             break;
                         case 1:
                             Tools.drawShadowString(g, (byte) 1, this.sArray[2], Constant.UI_START_X + 35 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4) * 3, 0xFFFF00, 0x000000);
                             break;
                         case 2:
                             Tools.drawShadowString(g, (byte) 1, this.sArray[3], Constant.UI_START_X + 35 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, Constant.UI_START_Y + 110 + (Constant.FONT_SMALL_HEIGHT + 4) * 3, 0x00FF00, 0x000000);
                             break;
                     }
                     if (this.bySelectIndex == 1) {
                         Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(i), this.shHeight, 310, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 33, Constant.UI_START_Y + 360, 0xFFFFFF, -1);
                     }
                 }
             }
         }
         Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 95, Constant.DRAW_WIDTH);
         if (this.bySelectIndex == 1 && this.bLock) {
             //宠物的操作
             this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, Constant.UI_START_X + 33 + 50 * (this.byItemSelectIndex - 1), Constant.UI_START_Y + 49);
         }
         //绘制技能图标
         for (byte i = 0; i < 12; i++) {
             if (i < 6) {
                 startX = Constant.UI_START_X + 33 + 50 * i;
                 startY = Constant.UI_START_Y + 267;
             } else {
                 startX = Constant.UI_START_X + 33 + 50 * (i - 6);
                 startY = Constant.UI_START_Y + 313;
             }
             this.items.drawItemBg(g, (byte) -1, startX, startY);
             //当前被选中的宠物
             if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                 //判端是否达到了最大的技能数量
                 if (i + 1 <= this.iArray[(this.byItemSelectIndex - 1) * 14 + 13]) {
                     //判断当前槽是否有技能
                     if (sHashtable.containsKey(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(1))) {
                         //绘制技能的图片
                         g.drawImage((Image) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(2))), startX + 7, startY + 7, 0);
                         //绘制技能的锁定图标
                         if (((String) sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(3))).equals("1")) {
                             g.drawImage(this.imgArray[9], startX + 14, startY + 14, 0);
                         }
                         if (this.bySubSelectIndex == i + 1 && (this.bySelectIndex == 2 || this.bySelectIndex == 3)) {
                             //绘制技能的描述
                             Tools.drawHCycleRollingParagraph(g, (String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(1))), this.shHeight, 310, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 33, Constant.UI_START_Y + 360, 0xFFFFFF, -1);
                         }
                     }
                 } else {
                     //超过最大的将格子叉掉
                     Tools.setColor(g, 0x000000);
                     g.drawLine(startX + 6, startY + 6, startX + 35, startY + 35);
                     g.drawLine(startX + 35, startY + 6, startX + 6, startY + 35);
                 }
             } else {
                 //没有宠物的技能格子叉掉
                 Tools.setColor(g, 0x000000);
                 g.drawLine(startX + 6, startY + 6, startX + 35, startY + 35);
                 g.drawLine(startX + 35, startY + 6, startX + 6, startY + 35);
             }
             if (this.bySubSelectIndex == i + 1) {
                 items.drawSelectStyle(g, startX, startY);
             }
         }
         if (this.bySelectIndex == 2 || this.bySelectIndex == 3) {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + 310 + (this.bySelectIndex - 2) * 45, Constant.DRAW_WIDTH);
             if (this.bLock) {
                 if (this.bySubSelectIndex <= 6) {
                     startX = Constant.UI_START_X + 33 + 50 * (this.bySubSelectIndex - 1);
                     startY = Constant.UI_START_Y + 267;
                 } else {
                     startX = Constant.UI_START_X + 33 + 50 * (this.bySubSelectIndex - 7);
                     startY = Constant.UI_START_Y + 313;
                 }
                 Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, startX, startY);
             }
         }
         if (this.byUiState == 1) {
             startY = Constant.UI_START_Y + ((Constant.END_LINE - 100) >> 1);
             Tools.drawPopUp(g, (byte) 4, Constant.UI_START_X + 25, startY, 310, 100, this.imgArray[3], 0x989898, imgArray[10], 22, 0, 21, 10, imgArray[10], 0, 0, 22, 10, this.sArray[4], null);
             //绘制输入方框
             Tools.setColor(g, 0xFFFFFF);
             g.fillRect(Constant.UI_START_X + 52, startY + 44, 260, 25);
             Tools.setColor(g, 0x000000);
             if (GameBean.STR_CMD_GOODS_NAME != null && GameBean.STR_CMD_GOODS_NAME.length() > 0) {
                 g.drawString(GameBean.STR_CMD_GOODS_NAME, Constant.UI_START_X + 53, startY + 44 + ((25 - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
             }
             if (bFlag) {
                 g.drawChar('|', Constant.UI_START_X + 54 + Constant.FONT_SMALL.stringWidth(GameBean.STR_CMD_GOODS_NAME), startY + 44 + ((25 - Constant.FONT_SMALL_HEIGHT) >> 1), 0);
             }
         }
         
         /////////////
         //Yujiang
         MainView.drawTouchRect(g, mPetEquipTouchRect);
         //
        //#else
//#        startY = Constant.UI_START_Y + UiInterFace.iScreenOffsetH;
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[10], this.sArray[11], this.sArray[0]);
//#         Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, startY + 255, Constant.DRAW_WIDTH, this.imgArray[8], 0, 0, 10, 57, Constant.TRANS_NONE);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[10], this.sArray[11], this.sArray[0]);
//#        Tools.drawTilePic(g, (byte) 1, Constant.UI_START_X, startY + 255, Constant.DRAW_WIDTH, this.imgArray[8], 0, 0, 10, 40, Constant.TRANS_NONE);
        //#endif
//#
//#        //绘制已经装备的宠物
//#        this.startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 220) >> 1);
//#        for (byte i = 0; i < 6; i++) {
//#            this.items.drawGoods(g, this.startX + 38 * i, startY + 28, i, false, false);
//#            if (i == this.byItemSelectIndex - 1) {
//#                this.items.drawSelectStyle(g, this.startX + 38 * i, startY + 28);
//#                //名称
//#                Tools.drawParagraph(g, this.startX, startY + 61, 240, this.sArray[5], 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, 0x000000);
//#                //潜能
//#                Tools.drawShadowString(g, (byte) 1, this.sArray[6], this.startX, startY + 61 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000);
//#                //名称
//#                Tools.drawShadowString(g, (byte) 1, this.sArray[7], this.startX, startY + 61 + (Constant.FONT_SMALL_HEIGHT << 1), 0xFFFFFF, 0x000000);
//#                //潜能
//#                Tools.drawShadowString(g, (byte) 1, this.sArray[8], this.startX, startY + 61 + Constant.FONT_SMALL_HEIGHT * 3, 0xFFFFFF, 0x000000);
//#                //名称
//#                Tools.drawShadowString(g, (byte) 1, this.sArray[9], this.startX, startY + 61 + (Constant.FONT_SMALL_HEIGHT << 2), 0xFFFFFF, 0x000000);
//#                if (this.items.checkColumnHasGoods(i)) {
//#                    //成长率图片
//#                    for (byte j = 0; j <= this.iArray[i * 14 + 2]; j++) {
//#                        g.drawImage(this.imgArray[7], startX + 2 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + j * 14, startY + 61 + Constant.FONT_SMALL_HEIGHT * 3, 0);
//#                    }
//#                    //类型
//#                    switch (this.iArray[i * 14]) {
//#                        case 0:
//#                            Tools.drawShadowString(g, (byte) 1, this.sArray[1], startX + 3 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, startY + 61 + Constant.FONT_SMALL_HEIGHT * 3, 0x00FF00, 0x000000);
//#                            break;
//#                        case 1:
//#                            Tools.drawShadowString(g, (byte) 1, this.sArray[2], startX + 3 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, startY + 61 + Constant.FONT_SMALL_HEIGHT * 3, 0xFFFF00, 0x000000);
//#                            break;
//#                        case 2:
//#                            Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX + 3 + Constant.FONT_SMALL.stringWidth(this.sArray[8]) + (this.iArray[i * 14 + 2] + 1) * 14, startY + 61 + Constant.FONT_SMALL_HEIGHT * 3, 0x00FF00, 0x000000);
//#                            break;
//#                    }
//#                    if (this.bySelectIndex == 1) {
                        //#if NOKIA_E72
                        //#else
//#                        Tools.drawHCycleRollingParagraph(g, this.items.getGoodsDesc(i), this.shHeight, 215, 36, Constant.FONT_SMALL_HEIGHT, startX, startY + 256, 0xFFFFFF, -1);
                        //#endif
//#                    }
//#                }
//#            }
//#//            }
//#        }
//#        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, startY + 60, Constant.DRAW_WIDTH);
//#        if (this.bySelectIndex == 1 && this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
//#            //宠物的操作
//#            if (bLock) {
//#                this.items.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, startX + 38 * (this.byItemSelectIndex - 1), startY + 28);
//#            }
//#        }
//#        //绘制技能图标
//#        for (byte i = 0; i < 12; i++) {
//#            if (i < 6) {
//#                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 220) >> 1) + 38 * i;
//#                startY = Constant.UI_START_Y + 190 + UiInterFace.iScreenOffsetH;
//#            } else {
//#                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 220) >> 1) + 38 * (i - 6);
//#                startY = Constant.UI_START_Y + 225 + UiInterFace.iScreenOffsetH;
//#            }
//#            this.items.drawItemBg(g, (byte) -1, startX, startY);
//#            //当前被选中的宠物
//#            if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
//#                //判端是否达到了最大的技能数量
//#                if (i + 1 <= this.iArray[(this.byItemSelectIndex - 1) * 14 + 13]) {
//#                    //判断当前槽是否有技能
//#                    if (sHashtable.containsKey(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(1))) {
//#                        //绘制技能的图片
//#                        g.drawImage((Image) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(2))), startX + 1, startY + 1, 0);
//#                        //绘制技能的锁定图标
//#                        if (((String) sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(3))).equals("1")) {
//#                            g.drawImage(this.imgArray[9], startX + 8, startY + 8, 0);
//#                        }
//#                        if (this.bySubSelectIndex == i + 1 && (this.bySelectIndex == 2 || this.bySelectIndex == 3)) {
//#                            //绘制技能的描述
//#                            Tools.drawHCycleRollingParagraph(g, (String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(i) + String.valueOf(1))), this.shHeight, 215, 36, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 215) >> 1), Constant.UI_START_Y + 256 + UiInterFace.iScreenOffsetH, 0xFFFFFF, -1);
//#                        }
//#                    }
//#                } else {
//#                    //超过最大的将格子叉掉
//#                    Tools.setColor(g, 0x000000);
//#                    g.drawLine(startX, startY, startX + 29, startY + 29);
//#                    g.drawLine(startX + 29, startY, startX, startY + 29);
//#                }
//#            } else {
//#                //没有宠物的技能格子叉掉
//#                Tools.setColor(g, 0x000000);
//#                g.drawLine(startX, startY, startX + 29, startY + 29);
//#                g.drawLine(startX + 29, startY, startX, startY + 29);
//#            }
//#            if (this.bySubSelectIndex == i + 1) {
//#                this.items.drawSelectStyle(g, startX, startY);
//#            }
//#        }
//#        if (this.bySelectIndex == 2 || this.bySelectIndex == 3) {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + UiInterFace.iScreenOffsetH + 222 + (this.bySelectIndex - 2) * 35, Constant.DRAW_WIDTH);
//#            if (this.bLock) {
//#                if (this.bySubSelectIndex <= 6) {
//#                    startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 220) >> 1) + 38 * (this.bySubSelectIndex - 1);
//#                    startY = Constant.UI_START_Y + 190 + UiInterFace.iScreenOffsetH;
//#                } else {
//#                    startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 220) >> 1) + 38 * (this.bySubSelectIndex - 7);
//#                    startY = Constant.UI_START_Y + 225 + UiInterFace.iScreenOffsetH;
//#                }
//#                Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, startX, startY);
//#            }
//#        }
//#        startY = Constant.UI_START_Y + UiInterFace.iScreenOffsetH;
//#        startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#        if (this.byUiState == 1) {
//#            Tools.drawPopUp(g, (byte) 4, startX, startY + ((Constant.DRAW_HEIGHT - 51) >> 1), 232, 51, this.imgArray[3], 0x989898, this.imgArray[5], 0, 0, 24, 12, this.imgArray[5], 49, 0, 23, 12, this.sArray[4], null);
//#            //绘制输入方框
//#            Tools.setColor(g, 0xFFFFFF);
//#            g.fillRect(startX + 6, startY + ((Constant.DRAW_HEIGHT - 51) >> 1) + 24, 222, 19);
//#            Tools.setColor(g, 0x000000);
//#            if (GameBean.STR_CMD_GOODS_NAME.length() > 0) {
//#                g.drawString(GameBean.STR_CMD_GOODS_NAME, startX + 8, startY + ((Constant.DRAW_HEIGHT - 51) >> 1) + 25, 0);
//#            }
//#            if (bFlag) {
//#                g.drawChar('|', startX + 9 + Constant.FONT_SMALL.stringWidth(GameBean.STR_CMD_GOODS_NAME), startY + ((Constant.DRAW_HEIGHT - 51) >> 1) + 25, 0);
//#            }
//#        }
        //#if NOKIA_E72
//#         Tools.drawE72ScrollBar(g);
        //#endif
        //#endif
    }

    /**
     * 更新宠物装备栏界面的逻辑
     */
    public void updatePetEquip() {
        if (!GameBean.b_WAIT_NET_MSG_BACK) {
            switch (this.byUiState) {
                case 0:
                    if (!this.bUiKeyPressLock) {
                        if (!this.bLock) {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex = (byte) (this.bySelectIndex - 1);
                                    switch (this.bySelectIndex) {
                                        case 1:
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(0);
                                            //#endif
                                            break;
                                        case 2:
                                            this.bySubSelectIndex = 1;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-80);
                                            //#endif
                                            break;
                                    }
                                    setRollText();
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 3) {
                                    this.bySelectIndex = (byte) (this.bySelectIndex + 1);
                                    switch (this.bySelectIndex) {
                                        case 2:
                                            this.bySubSelectIndex = 1;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-80);
                                            //#endif
                                            break;
                                        case 3:
                                            this.bySubSelectIndex = 7;
                                            //#if NOKIA_E72
//#                                             Tools.updateE72ScollBar(-80);
                                            //#endif
                                            break;
                                    }
                                    setRollText();
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        this.byItemSelectIndex = (byte) (this.byItemSelectIndex > 1 ? this.byItemSelectIndex - 1 : 6);
                                        this.bySubSelectIndex = 1;
                                        this.setPetString((byte) (this.byItemSelectIndex - 1));
                                        break;
                                    case 2:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex > 1 ? this.bySubSelectIndex - 1 : 6);
                                        break;
                                    case 3:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex > 7 ? this.bySubSelectIndex - 1 : 12);
                                        break;
                                }
                                setRollText();
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                        this.byItemSelectIndex = (byte) (this.byItemSelectIndex < 6 ? this.byItemSelectIndex + 1 : 1);
                                        this.bySubSelectIndex = 1;
                                        this.setPetString((byte) (this.byItemSelectIndex - 1));
                                        break;
                                    case 2:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex < 6 ? this.bySubSelectIndex + 1 : 1);
                                        break;
                                    case 3:
                                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex < 12 ? this.bySubSelectIndex + 1 : 7);
                                        break;
                                }
                                setRollText();
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                                    || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)
                                    || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                if (!this.bShowOtherPlayerPet) {
                                    if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                                        this.byMenuIndex = 0;
                                        if (this.bySelectIndex == 1) {
                                            this.bLock = true;
                                            if (this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] == 1) {
                                                this.sOpArray = this.items.getPetOperation(Constant.ITEM_COLUMN_TYPE_PET_EQUIP, (byte) 1);
                                            } else {
                                                this.sOpArray = this.items.getPetOperation(Constant.ITEM_COLUMN_TYPE_PET_EQUIP, (byte) 0);
                                            }
                                        } else if ((this.bySelectIndex == 2 || this.bySelectIndex == 3)) {
                                            //判读当前是否有技能和锁定请情况
                                            if (this.sHashtable.containsKey(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(1))) {
                                                this.bLock = true;
                                                this.byMenuIndex = 0;
                                                if (((String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(3)))).equals("1")) {
                                                    this.sOpArray = new String[]{"解锁", "遗忘"};
                                                } else {
                                                    this.sOpArray = new String[]{"锁定", "遗忘"};
                                                }
                                            }
                                        }
                                    } else {
                                        this.byPetOperation = 10;//装备宠物
                                        MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_PET);
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                if (!this.bShowOtherPlayerPet) {
                                    Tools.openRoamMenu(false, (byte) 1, (byte) 6, 1);
                                } else {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    GameBean.L_PLAYER_ID = this.lOtherPlayerID;
                                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_OTHER_PLAYER_DETAIL, Constant.SOCKET_MSG_TYPE_LOGIC);
                                }
                            }
                        } else {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                                    || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)
                                    || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                this.bLock = false;
                                if (this.bySelectIndex == 1) {
                                    switch (this.byMenuIndex) {
                                        case 0:
                                            //改名
                                            this.bLockChangePetAlias = false;
                                            this.byUiState = 0;
                                            GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                                            GameBean.STR_CMD_GOODS_NAME = this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1));
                                            MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "宠物改名");
                                            MainLogic.getInstance().inputInterFace.commonInput.setString(GameBean.STR_CMD_GOODS_NAME);
                                            MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            this.byPetOperation = 1;// 改名
                                            break;
                                        case 1:
                                            if (this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] == 1) {
                                                this.byPetOperation = 2;// 休息
                                                //休息
                                                GameBean.BY_OP_TYPE = 2;//休息
                                                this.items.sendGoodsOperationMSG((short) (this.byItemSelectIndex - 1), this.sOpArray, this.byMenuIndex);
                                                this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] = 0;
                                                this.setPetString((byte) (this.byItemSelectIndex - 1));
                                                MainLogic.getInstance().gamePlayer.deletePetsAni();
                                            } else {
                                                //守护
                                                this.byPetOperation = 3;// 守护
                                                GameBean.BY_OP_TYPE = 1;//守护
                                                if (this.iArray[(this.byItemSelectIndex - 1) * 14 + 6] <= 20) {
                                                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的宠物快乐度小于20，不能守护!");
                                                    return;
                                                }
                                                this.items.sendGoodsOperationMSG((short) (this.byItemSelectIndex - 1), this.sOpArray, this.byMenuIndex);
                                                this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] = 1;
                                                this.setPetString((byte) (this.byItemSelectIndex - 1));
                                                for (byte i = 0; i < 6; i++) {
                                                    if (this.items.checkColumnHasGoods(i) && i != this.byItemSelectIndex - 1) {
                                                        this.iArray[i * 14 + 3] = 0;
                                                    }
                                                }
                                                MainLogic.getInstance().gamePlayer.addPetsAni(this.iAvatarID[this.byItemSelectIndex - 1], this.shPetState[this.byItemSelectIndex - 1], this.items.getGoodsAlias((short) (this.byItemSelectIndex - 1)), (byte) iArray[(this.byItemSelectIndex - 1) * 14 + 6]);
                                            }
                                            break;
                                        case 2:
                                            this.byPetOperation = 4;// 喂养
                                            GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((byte) (this.byItemSelectIndex - 1));
                                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                            //喂养
                                            break;
                                        case 3:
                                            this.byPetOperation = 5;// 使用道具
                                            //道具(宠物使用物品)
                                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                                            break;
                                        case 4:
                                            //卸下
                                            if (this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] == 1) {
                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请先让宠物休息，才可以卸载!");
                                            } else {
                                                this.byPetOperation = 9;//卸下
                                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                                GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_DELETE_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            }
                                            break;
                                    }
                                } else if (this.bySelectIndex == 2 || this.bySelectIndex == 3) {
                                    this.bLock = false;
                                    switch (this.byMenuIndex) {
                                        case 0:
                                            //技能的锁定和解除锁定
                                            if (((String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(3)))).equals("1")) {
                                                this.byPetOperation = 6;// 技能解锁
                                                GameBean.BY_TYPE = 2;
                                            } else {
                                                this.byPetOperation = 7;// 技能锁定
                                                GameBean.BY_TYPE = 1;
                                            }
                                            //发送宠物技能锁定或是解锁
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                                            GameBean.I_CMD_COLUMN_INDEX = (this.bySubSelectIndex - 1);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_LOCK_SKILL, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            break;
                                        case 1:
                                            //遗忘技能
                                            this.byPetOperation = 8;// 技能遗忘
                                            GameBean.BY_TYPE = 3;
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                                            GameBean.I_CMD_COLUMN_INDEX = (this.bySubSelectIndex - 1);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_LOCK_SKILL, Constant.SOCKET_MSG_TYPE_LOGIC);
                                            break;
                                    }
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                this.bLock = false;
                            }
                        }
                    }
                    break;
                case 1:
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                        if (!this.bLockChangePetAlias) {
                            MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "宠物改名");
                            MainLogic.getInstance().inputInterFace.commonInput.setString(GameBean.STR_CMD_GOODS_NAME);
                            MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                        } else {
                            if (GameBean.STR_CMD_GOODS_NAME != null && GameBean.STR_CMD_GOODS_NAME.length() > 1 && GameBean.STR_CMD_GOODS_NAME.length() < 15) {
                                this.byUiState = 0;
                                GameBean.b_WAIT_NET_MSG_BACK = true;
                                GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                                Tools.printLog("发送宠物改名" + GameBean.L_CMD_PET_SLOTKEY + GameBean.STR_CMD_GOODS_NAME);
                                MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_CHANGE_ALIAS, Constant.SOCKET_MSG_TYPE_LOGIC);
                            } else {
                                this.byUiState = 0;
                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物名字长度最多6个汉字!");
                            }
                        }

                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                    this.bFlag = this.bFlag ? false : true;
                    break;
                case 2:
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)
                            || MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                    break;
            }
        }
        MainCanvas.clearInput();
    }

    /**
     * 被选中那个技能的描述
     */
    public void setRollText() {
        switch (this.bySelectIndex) {
            case 1:
                if (this.items.checkColumnHasGoods((short) (this.byItemSelectIndex - 1))) {
                    //#if NOKIA_S60V5
                     this.shHeight = (short) Tools.getParagraphHeight(this.items.getGoodsDesc((short) (this.byItemSelectIndex - 1)), 310, Constant.FONT_SMALL_HEIGHT);
                    //#else
//#                    this.shHeight = (short) Tools.getParagraphHeight(this.items.getGoodsDesc((short) (this.byItemSelectIndex - 1)), 215, Constant.FONT_SMALL_HEIGHT);
                    //#endif
                    Tools.rollIndex = 0;
                    Tools.lastUpdateTime = System.currentTimeMillis();
                } else {
                    this.shHeight = 0;
                }
                break;
            case 2:
            case 3:
                if (this.sHashtable.containsKey(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(1))) {
                    //#if NOKIA_S60V5
                     this.shHeight = (short) Tools.getParagraphHeight((String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(1))), 310, Constant.FONT_SMALL_HEIGHT);
                    //#else
//#                    this.shHeight = (short) Tools.getParagraphHeight((String) (this.sHashtable.get(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(1))), 215, Constant.FONT_SMALL_HEIGHT);
                    //#endif
                    Tools.rollIndex = 0;
                    Tools.lastUpdateTime = System.currentTimeMillis();
                } else {
                    this.shHeight = 0;
                }
                break;
        }
    }

    /**
     * 更改宠物名称
     * @param stateCode 
     */
    public void changePetAlias(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 1:
                this.items.sAlias[this.byItemSelectIndex - 1] = GameBean.STR_CMD_GOODS_NAME;
                //判断是否是守护状态
                if (this.iArray[(this.byItemSelectIndex - 1) * 14 + 3] == 1) {
                    MainLogic.getInstance().gamePlayer.sPetNick = GameBean.STR_CMD_GOODS_NAME;
                }
                GameBean.STR_CMD_GOODS_NAME = null;
                this.setPetString((byte) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物改名成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物名字长度最多6个汉字！");
                break;
            default:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物改名失败");
                break;
        }
    }

    /**
     * 宠物技能的锁定和解锁
     */
    public void petLockSkill(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        Tools.printLog("this.byMenuIndex=" + this.byMenuIndex);
        if (GameBean.BY_TYPE == 2) {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能解锁失败");
                    break;
                case 1:
                    this.sHashtable.put(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(3), String.valueOf(0));
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能解锁成功");
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "缺少物品“黄晶石”!");
                    break;
            }
        } else if (GameBean.BY_TYPE == 1) {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能锁定失败");
                    break;
                case 1:
                    this.sHashtable.put(String.valueOf(this.byItemSelectIndex - 1) + String.valueOf(this.bySubSelectIndex - 1) + String.valueOf(3), String.valueOf(1));
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能锁定成功");
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "缺少物品”金玉环“");
                    break;
            }
        } else if (GameBean.BY_TYPE == 3) {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能遗忘失败");
                    break;
                case 1:
                    this.removeSkillHash((byte) (this.byItemSelectIndex - 1), (byte) (this.iArray[(this.byItemSelectIndex - 1) * 14 + 13]), (byte) (this.bySubSelectIndex - 1));
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能遗忘成功");
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "缺少物品“遗忘丹”");
                    break;
            }
        }
    }

    /**
     * 清除宠物装备栏的资源
     */
    public void clearPetEquip() {
        this.imgArray = null;
        this.sArray = null;
        this.iArray = null;
        this.sOpArray = null;
        this.shPetState = null;
        this.iAvatarID = null;
        this.sHashtable = null;
        this.items = null;
        this.sOtherPlayerNick = null;
        this.lOtherPlayerID = -1;
        //#if NOKIA_E72
//#         Tools.clearE72ScollBar();
        //#endif
    }

    /**********************潜能激发界面潜能激发界面潜能激发界面潜能激发界面******************************/
    /**
     * 初始化宠物潜能激发界面资源
     */
    public void initPetPowerStrength() {
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[9];
             this.imgArray[0] = ResManager.createImage(90000041); //小箭头图片
             this.imgArray[1] = Tools.makeBlueMask(); //蓝色选择条
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255); //边框图片
             this.imgArray[7] = ResManager.createImage(90000086);//蓝条
             this.imgArray[5] = ResManager.createImage(90000043);  //文字图片
             this.imgArray[6] = ResManager.createImage(90000085);//确认按钮图片
             this.imgArray[4] = ResManager.createImage(90000049); //星星图片
             this.imgArray[8] = ResManager.createImage(90000084);//方向键图片
            //#else
//#            this.imgArray = new Image[6];
//#            //箭头图片
//#            this.imgArray[0] = ResManager.createImage(90000041);
//#            //蓝色光片
//#            this.imgArray[1] = Tools.makeBlueMask();
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            //背景图片
//#            this.imgArray[2] = ResManager.createImage(90000017);
            //#endif
//#            //边框图片
//#            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            //文字图片
//#            this.imgArray[5] = ResManager.createImage(90000043);
//#            //星星图片
//#            this.imgArray[4] = ResManager.createImage(90000049);
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        this.byItemSelectIndex = 1;
        //分解
        this.sArray = new String[]{"宠物潜能激发", "潜能激发", "喂养", "请选择宠物", "潜能：", "/", "喂食道具", "平凡", "优秀", "杰出", "完美", "喂食成功!", "", "返回", "等级："};
        items = new Goods((short) 2, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "叶凡轮动阴阳圣剑，将紫府圣子斩死，头颅与神识成为灰烬，只刺下一具无头的尸体在喷涌鲜血", (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, "", (short) 10, 5, (byte) 99, "10031");
//        this.items.sGoodsDesc[1] = "让宠物保留现有技能和潜能激发效果，同时等级变成1级，并重新分配宠物的成长率";
//        this.shPetState = new short[]{150, 150, 3, 4};
//        "当前潜能" + shPetState[0] + "总的潜能" + shPetState[1] / "资质" + shPetState[2] + "成长率=" + shPetState[3]; 
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 22;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 45;
        //#endif
    }

    /**
     * 绘制宠物潜能激发界面
     */
    public void drawPetPowerStrength(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[8], this.imgArray[6], this.imgArray[7], this.imgArray[5], 52, 2, 43, 22, this.imgArray[5], 0, 156, 45, 24, this.sArray[0]);
         byte byGapH = 20;
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[2], this.sArray[13], this.sArray[0]);
//#         byte byGapH = 10;
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[2], this.sArray[13], this.sArray[0]);
//#        byte byGapH = 4;
        //#endif
        startY = this.iStartPointY;
        startX = Constant.UI_START_X + byGapH;
        int w = Constant.DRAW_WIDTH - (byGapH << 1);
        int h = Goods.byItemH + 14;
        h = h < Constant.FONT_SMALL_HEIGHT * 3 + 14 ? Constant.FONT_SMALL_HEIGHT * 3 + 14 : h;
        //宠物背景
        Tools.drawRoundRect(g, this.imgArray[3], 0x989898, w, h, startX, startY);
        //绘制宠物
        this.items.drawGoods(g, startX + 7, startY + 7, (short) 0);
        if (this.byItemSelectIndex == 1) {
            this.items.drawSelectStyle(g, startX + 7, startY + 7);
        }
        //绘制宠物名称
        if (this.items.checkColumnHasGoods((short) 0)) {
            //宠物名称
            this.items.drawGoodsName(g, (short) 0, startX + 9 + Goods.byItemH, startY + 7);
            //等级
            Tools.drawShadowString(g, (byte) 1, this.sArray[14] + String.valueOf(this.items.getGoodsLevel((short) 0)), startX + 9 + Goods.byItemH, startY + 8 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000);
            //绘制成长率
            for (byte i = 0; i <= this.shPetState[3]; i++) {
                g.drawImage(this.imgArray[4], startX + w - (i + 1) * 14 - 7, startY + 7, 0);
            }
            //绘制潜能
            Tools.drawShadowString(g, (byte) 1, this.sArray[4] + String.valueOf(this.shPetState[0]) + this.sArray[5] + String.valueOf(this.shPetState[1]), startX + 9 + Goods.byItemH, startY + 9 + (Constant.FONT_SMALL_HEIGHT << 1), 0xFFFFFF, 0x000000);
            //宠物资质
            Tools.drawShadowString(g, (byte) 1, this.sArray[7 + this.shPetState[2]], startX + w - 7, startY + 8 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
        } else {
            Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX + 9 + Goods.byItemH, startY + 7, Constant.SELECTED_COLOR, 0x000000);
        }

        //绘制宠物喂食物品
        this.startY += h + 10;
        h = Constant.FONT_SMALL_HEIGHT * 6 + 14;
        Tools.drawRoundRect(g, this.imgArray[3], 0x989898, w, h, startX, startY);
        this.items.drawGoods(g, startX + 7, startY + 7, (short) 1);
        if (this.byItemSelectIndex == 2) {
            this.items.drawSelectStyle(g, startX + 7, startY + 7);
        }
        if (this.items.checkColumnHasGoods((short) 1)) {
            this.items.drawGoodsName(g, (short) 1, startX + 7 + Goods.byItemH, startY + 7);
            //等级
            Tools.drawShadowString(g, (byte) 1, this.sArray[14] + String.valueOf(this.items.getGoodsLevel((short) 1)), startX + 7 + Goods.byItemH + this.items.getGoodsAlias((short) 1).length() * Constant.FONT_CHAR_WIDTH + 10, startY + 7, 0xFFFFFF, 0x000000);
            Tools.drawParagraph(g, startX + 7 + Goods.byItemH, startY + 8 + Constant.FONT_SMALL_HEIGHT, w - 15 - Goods.byItemH, this.items.getGoodsDesc((short) 1), 0xFFFFFF, Constant.FONT_SMALL_HEIGHT, 0x000000);
        } else {
            Tools.drawShadowString(g, (byte) 1, this.sArray[6], startX + 7 + Goods.byItemH, startY + 7, Constant.SELECTED_COLOR, 0x000000);
        }
        
        /////////////
        //Yujiang
        MainView.drawTouchRect(g, mPetPowerStrengthTouchRect);
    }

    /**
     * 更新宠物潜能激发界面逻辑
     */
    public void updatePetPowerStrength() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            MainCanvas.clearInput();
            return;
        }
        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
            this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 2 : 1);
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
            switch (this.byItemSelectIndex) {
                case 1:
                    MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_PET);
                    break;
                case 2:
                    MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_COMMON);
                    break;
            }
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
            if (!this.items.checkColumnHasGoods((short) 0)) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择潜能激发宠物");
                return;
            } else if (!this.items.checkColumnHasGoods((short) 1)) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您没有选择宠物潜能激发道具");
                return;
            }
            GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
            GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 1);
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_FUNC_POTENTIAL_EXCITE, Constant.SOCKET_MSG_TYPE_LOGIC);
            //发送潜能激发
        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
            Tools.openRoamMenu(false, (byte) 1, (byte) 6, 2);
        }


    }

    /**
     * 清除宠物潜能激发界面资源
     */
    public void clearPetPowerStrength() {
        this.sArray = null;
        this.imgArray = null;
        this.items = null;
        this.shPetState = null;
    }

    /**
     * 在背包中选着激发潜能的宠物或是喂食物品
     */
    public void petPowerStrengthItems(byte stateCode, byte bySelectType, Goods packageGoods, short shPos, String desc, short[] shPetState) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        if (stateCode == 1) {
            if (bySelectType == 1) {
                this.shPetState = shPetState;
                this.items.goodsClone((short) 0, packageGoods, shPos);
            } else if (bySelectType == 2) {
                this.items.goodsClone((short) 1, packageGoods, shPos);
                this.items.setGoodsDesc((short) 1, desc, false);
                Tools.printLog("items=" + items.getGoodsAlias((short) 1) + items.getGoodsDesc((short) 1));
            }
            this.sArray[12] = null;
            MainLogic.getInstance().uiPackage.closeBag();
        } else if (stateCode == 2) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "选择潜能激发道具示失败");
        } else {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是潜能激发道具");
        }
    }

    /**
     * 从背包中选择宠物潜能激发物品
     * @param packageGoods
     * @param shPos 
     */
    public void selectPetPowerStrengthItems(Goods packageGoods, short shPos) {
        if (this.byItemSelectIndex == 1) {
            if (packageGoods.getGoodsCatalog(shPos) != Constant.ITEM_TYPE_PETS) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是宠物道具，请重新选择!");
                return;
            }
            GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
            GameBean.BY_TYPE = 1;
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SELECT_PET_POTENTIAL_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);

        } else if (this.byItemSelectIndex == 2) {
            if (packageGoods.getColumnType() != Constant.ITEM_COLUMN_TYPE_COMMON) {
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是宠物潜能激发道具!!");
                return;
            }
            GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
            GameBean.BY_TYPE = 2;
            GameBean.b_WAIT_NET_MSG_BACK = true;
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SELECT_PET_POTENTIAL_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
        }
    }

    /**
     * 宠物潜能激发结果
     */
    public void PetPowerExcite(byte stateCode, byte byPetDisapper, short shCurrentPower, short shTotalPower, String desc, byte byGrowth) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物潜能激发出错!");
                break;
            case 1:
                if (byPetDisapper == 1) {
                    this.items.deleteGoods((short) 0);
                    this.shPetState = null;
                } else {
                    if (desc != null) {
                        this.sArray[12] = "喂食成功!|" + desc;
                        Tools.printLog(" this.sArray[12]=" + this.sArray[12]);
                    } else {
                        this.sArray[12] = "喂食成功!";
                    }
                }
                if (!(this.shPetState[0] == shCurrentPower && this.shPetState[1] == shTotalPower && this.shPetState[3] == byGrowth)) {
                    this.shPetState[0] = shCurrentPower;
                    this.shPetState[1] = shTotalPower;
                    this.shPetState[3] = byGrowth;
                    if (this.items.getGoodsStackNum((short) 1) > 1) {
                        this.items.shStackNum[1] -= 1;
                    } else {
                        this.items.deleteGoods((short) 1);
                    }
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", this.sArray[12]);
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是宠物潜能激发道具!!");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您宠物潜能不足，无法继续潜能激发。请使用潜能成长石或者轮回石提升宠物潜能。");
                break;

        }
    }
    /***********************************宠物合成界面*******************************************/
    /**
     * 初始化宠物合成界面资源
     */
    public String[] sPetSkillNameDesc;

    public void initPetCompose() {
        this.bLock = false;
        this.sArray = new String[]{"宠物合成", "主位：", "副位：", "平凡", "优秀", "杰出", "完美", "合成", "返回"};
        sPetSkillNameDesc = new String[24];
        this.sOpArray = new String[]{"查看"};
        this.bySelectIndex = 1;
        this.byItemSelectIndex = 1;
        //索引位置代表的意思:0:主宠的资质;1:主宠的成长;2:主宠的宠物槽数量;3:副宠的资质;4:副宠的成长;5:副宠的宠物槽数量;
        this.shPetState = new short[]{-1, -1, -1, -1, -1, -1};
        //key组成：:宠物类型(1,主宠，2,副宠)+技能槽索引(0-12)+类型(1,名称描述,2,技能图片,3技能锁定情况)
        this.sHashtable = new Hashtable();
        this.items = new Goods((short) 2, Constant.ITEM_COLUMN_TYPE_PET);
//        //key组成,宠物索引+技能槽索引+类型(1,描述,2:图片)//byte byPetIndex, byte bySkillIndex, int iconID, String sSkillName, byte byLevel, byte bySkillLock, String desc
        /******/
//        this.setSkillHashTable((byte) 0, (byte) 0, 1171, "强力一击", (byte) 1, (byte) 0, "给任务添加滋生攻击的10%，并有持续的伤害效果!");
//        this.setSkillHashTable((byte) 1, (byte) 0, 1181, "强力一击", (byte) 2, (byte) 1, "给任务添加滋生攻击的10%，并有持续的伤害效果!");
//
//        this.items.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.items.addGoods((short) 1, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.shPetState = new short[]{2, 2, 5, 3, 4, 7};
//        sPetSkillNameDesc = new String[24];
//        sPetSkillNameDesc[0] = "强力一击|等级:13";
//        sPetSkillNameDesc[12] = "强力一击|等级:15";
        /*******/
        try {
            //#if NOKIA_S60V5
             this.imgArray = new Image[11];
             this.imgArray[0] = ResManager.createImage(90000041); //小箭头图片
             this.imgArray[1] = Tools.makeBlueMask(); //蓝色选择条
             this.imgArray[2] = ResManager.createImage(90000017);//背景图片
             this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255); //边框图片
             this.imgArray[9] = ResManager.createImage(90000086);//蓝条
             this.imgArray[5] = ResManager.createImage(90000043);  //文字图片
             this.imgArray[7] = ResManager.createImage(90000085);//确认按钮图片
             this.imgArray[6] = ResManager.createImage(90000049); //星星图片
             this.imgArray[8] = ResManager.createImage(90000084);//方向键图片
             this.imgArray[4] = ResManager.createImage(90000034);//技能锁
             this.imgArray[10] = ResManager.createImage(90000049);//星星图片
            //#else
//#            imgArray = new Image[7];
//#            //箭头图片
//#            this.imgArray[0] = ResManager.createImage(90000041, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
//#            //蓝色光片
//#            this.imgArray[1] = Tools.makeBlueMask();
            //#if NOKIA_S40V3 || MOTO || K790
            //#elif NORMAL_240_400
//# //            imgArray[2] = ResManager.createImage(90000017);
//# //            imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
            //#else
//#            //背景图片
//#            //背景图片
//#            this.imgArray[2] = ResManager.createImage(90000017, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
            //#endif
//#            //边框图片
//#            this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#            //技能锁定图平
//#            this.imgArray[4] = ResManager.createImage(90000034);
//#            //文字图片
//#//            this.imgArray[5] = ResManager.createImage(90000043, Constant.RES_PUBLIC_TEMP, Constant.RES_UI_PATH, false, -1);
//#            //星星图片
//#            this.imgArray[6] = ResManager.createImage(90000049);
            //#endif
        } catch (Exception e) {
            if (Constant.DEBUG) {
                e.printStackTrace();
            }
        }
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 54;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 22;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 45;
        //#endif
    }

    /**
     * 设置滚动文字
     */
    private void setPetComposeRollText() {
        if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.items.checkColumnHasGoods((short) (this.bySelectIndex - 1))) {
            if (this.byItemSelectIndex == 1) {
                Tools.rollIndex = 0;
                Tools.lastUpdateTime = System.currentTimeMillis();
                //#if NOKIA_S60V5
                 this.shHeight = (short) Tools.getParagraphHeight(this.items.getGoodsDesc((short) (this.bySelectIndex - 1)), 310, Constant.FONT_SMALL_HEIGHT);
                //#else
//#                this.shHeight = (short) Tools.getParagraphHeight(this.items.getGoodsDesc((short) (this.bySelectIndex - 1)), 215, Constant.FONT_SMALL_HEIGHT);
                //#endif
            } else if (this.byItemSelectIndex > 1 && this.byItemSelectIndex < 13 && this.sHashtable.containsKey(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))) {
                Tools.rollIndex = 0;
                Tools.lastUpdateTime = System.currentTimeMillis();
                //#if NOKIA_S60V5
                 this.shHeight = (short) Tools.getParagraphHeight((String) (this.sHashtable.get(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))), 310, Constant.FONT_SMALL_HEIGHT);
                //#elif NOKIA_E72
//#                 this.shHeight = (short) Tools.getParagraphHeight((String) (this.sHashtable.get(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))), 100, Constant.FONT_SMALL_HEIGHT);
                //#else
//#                this.shHeight = (short) Tools.getParagraphHeight((String) (this.sHashtable.get(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))), 215, Constant.FONT_SMALL_HEIGHT);
                //#endif
            }
        }
    }

    /**
     * 更新宠物合成逻辑
     */
    public void updatePetCompose() {
        if (GameBean.b_WAIT_NET_MSG_BACK) {
            MainCanvas.clearInput();
        }
        if (!bLock) {
            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                this.bySelectIndex = (byte) (this.bySelectIndex == 1 ? 2 : 1);
                this.byItemSelectIndex = 1;
                this.makeItemsTips(items, (short) (this.bySelectIndex == 1 ? 0 : 1));
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                this.bySelectIndex = (byte) (this.bySelectIndex == 2 ? 1 : 2);
                this.byItemSelectIndex = 1;
                this.makeItemsTips(items, (short) (this.bySelectIndex == 1 ? 0 : 1));
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
                    this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 1 ? 13 : this.byItemSelectIndex - 1);
                    if (this.byItemSelectIndex == 1) {
                        this.makeItemsTips(items, (short) (this.bySelectIndex == 1 ? 0 : 1));
                    } else {
                        this.makeSkillTips((byte) (this.bySelectIndex - 1), (byte) (this.byItemSelectIndex - 2));
                    }
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
                    this.byItemSelectIndex = (byte) (this.byItemSelectIndex == 13 ? 1 : this.byItemSelectIndex + 1);
                    if (this.byItemSelectIndex == 1) {
                        this.makeItemsTips(items, (short) (this.bySelectIndex == 1 ? 0 : 1));
                    } else {
                        this.makeSkillTips((byte) (this.bySelectIndex - 1), (byte) (this.byItemSelectIndex - 2));
                    }
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                switch (this.bySelectIndex) {
                    case 1:
                        if (this.byItemSelectIndex == 1) {
                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_PET);
                        } else if (this.byItemSelectIndex > 1 && this.byItemSelectIndex < 14 && sHashtable.containsKey(String.valueOf(0) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))) {
                            this.bLock = true;
                        }
                        break;
                    case 2:
                        if (this.byItemSelectIndex == 1) {
                            MainLogic.getInstance().uiPackage.showBag(Constant.ITEM_COLUMN_TYPE_PET);
                        } else if (this.byItemSelectIndex > 1 && this.byItemSelectIndex < 14 && sHashtable.containsKey(String.valueOf(1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))) {
                            this.bLock = true;
                        }
                        break;
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                if (this.items.checkColumnHasGoods((short) 0) && this.items.checkColumnHasGoods((short) 1)) {
                    GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) 0);
                    GameBean.L_CMD_GOODS_SLOTKEY = this.items.getGoodsColumnKey((short) 1);
                    if (GameBean.L_CMD_PET_SLOTKEY == GameBean.L_CMD_GOODS_SLOTKEY) {
                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的宠物和副宠是同一个宠物!");
                        return;
                    }
                    GameBean.b_WAIT_NET_MSG_BACK = true;
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_PET_COMPOSE, Constant.SOCKET_MSG_TYPE_LOGIC);
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "至少要两个宠物才可以合成");
                }
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                Tools.openRoamMenu(false, (byte) 1, (byte) 6, 3);
            }
        } else {
            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                this.bLock = false;
            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                this.bLock = false;
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("技能描述", (String) (sHashtable.get(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))));
            }
        }
    }

    /**
     * 绘制宠物合成界面
     * @param g
     */
    public void drawPetCompose(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[8], this.imgArray[7], this.imgArray[9], this.imgArray[5], 52, 2, 43, 22, this.imgArray[5], 247, 106, 45, 21, this.sArray[0]);
        //#elif NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[7], this.sArray[8], this.sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[7], this.sArray[8], this.sArray[0]);
        //#endif
        int w = Goods.byItemH * 7 + 20;
        int h = (Goods.byItemH << 1) + Constant.FONT_SMALL_HEIGHT + 22;
        byte byIconStart = (byte) Tools.ceil(Goods.byItemH - 30, 2);
        this.startY = this.iStartPointY;
        this.startX = Constant.UI_START_X + (Constant.DRAW_WIDTH - w >> 1);
        Tools.drawRoundRect(g, this.imgArray[3], 0x989898, w, h, this.startX, this.startY);
        this.items.drawGoods(g, this.startX + 7, this.startY + (h - Goods.byItemH >> 1), (short) 0);
        //主宠的名称和资质
        Tools.drawShadowString(g, (byte) 1, this.sArray[1], startX + 7, this.startY + 5, 0x00CCFF, 0x000000);
        if (this.items.checkColumnHasGoods((short) 0)) {
            this.items.drawGoodsName(g, (short) 0, startX + 7 + Constant.FONT_SMALL.stringWidth(this.sArray[2]), this.startY + 5);
            //绘制成长
            for (byte i = 0; i <= this.shPetState[1]; i++) {
                g.drawImage(this.imgArray[6], startX + w - 7 - (i + 1) * 14, startY + 3, 0);
            }
            switch (this.shPetState[0]) {
                case 0:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 1:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[4], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 2:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[5], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 3:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[6], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
            }
        }
        //主宠的技能
        for (byte i = 0; i < 12; i++) {
            if (i < 6) {
                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - w) >> 1) + 14 + Goods.byItemH + (Goods.byItemH - 1) * i;
                startY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20;
            } else {
                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - w) >> 1) + 14 + Goods.byItemH + (Goods.byItemH - 1) * (i - 6);
                startY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH - 1;
            }
            this.items.drawItemBg(g, (byte) -1, startX, startY);
            if (this.items.checkColumnHasGoods((short) 0) && i + 1 <= this.shPetState[2]) {
                //判断当前槽是否有技能
                if (sHashtable.containsKey(String.valueOf(0) + String.valueOf(i) + String.valueOf(1))) {
                    //绘制技能的图片
                    g.drawImage((Image) (this.sHashtable.get(String.valueOf(0) + String.valueOf(i) + String.valueOf(2))), startX + byIconStart, startY + byIconStart, 0);
                    //绘制技能的锁定图标
                    if (((String) sHashtable.get(String.valueOf(0) + String.valueOf(i) + String.valueOf(3))).equals("1")) {
                        g.drawImage(this.imgArray[4], startX + Goods.byItemH - byIconStart - 15, startY + byIconStart, 0);
                    }
                }
            } else {
                //没有宠物的技能格子叉掉
                Tools.setColor(g, 0x000000);
                g.drawLine(startX + byIconStart, startY + byIconStart, startX + 29 + byIconStart, startY + 29 + byIconStart);
                g.drawLine(startX + 29 + byIconStart, startY + byIconStart, startX + byIconStart, startY + 29 + byIconStart);
            }
        }

        //副宠
        this.startY = this.iStartPointY + h + 5;
        this.startX = Constant.UI_START_X + (Constant.DRAW_WIDTH - w >> 1);
        Tools.drawRoundRect(g, this.imgArray[3], 0x989898, w, h, this.startX, this.startY);
        this.items.drawGoods(g, startX + 7, this.startY + (h - Goods.byItemH >> 1), (short) 1);
        //副宠的名称和资质
        Tools.drawShadowString(g, (byte) 1, this.sArray[2], this.startX + 7, this.startY + 5, 0x00CCFF, 0x000000);
        if (this.items.checkColumnHasGoods((short) 1)) {
            this.items.drawGoodsName(g, (short) 1, startX + 7 + Constant.FONT_SMALL.stringWidth(this.sArray[2]), startY + 5);
            //绘制成长
            for (byte i = 0; i <= this.shPetState[4]; i++) {
                g.drawImage(this.imgArray[6], startX + w - 7 - (i + 1) * 14, this.startY + 3, 0);
            }
            switch (this.shPetState[3]) {
                case 0:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 1:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[4], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 2:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[5], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
                case 3:
                    Tools.drawShadowString(g, (byte) 1, this.sArray[6], startX + w - 7, startY + 3 + Constant.FONT_SMALL_HEIGHT, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
                    break;
            }
        }
        //宠物的技能
        for (byte i = 0; i < 12; i++) {
            if (i < 6) {
                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - w) >> 1) + 14 + Goods.byItemH + (Goods.byItemH - 1) * i;
                startY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + h + 5;
            } else {
                startX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - w) >> 1) + 14 + Goods.byItemH + (Goods.byItemH - 1) * (i - 6);
                startY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH - 1 + h + 5;
            }
            this.items.drawItemBg(g, (byte) -1, startX, startY);
            if (this.items.checkColumnHasGoods((short) 1) && i + 1 <= this.shPetState[5]) {
                //判断当前槽是否有技能
                if (sHashtable.containsKey(String.valueOf(1) + String.valueOf(i) + String.valueOf(1))) {
                    //绘制技能的图片
                    g.drawImage((Image) (this.sHashtable.get(String.valueOf(1) + String.valueOf(i) + String.valueOf(2))), startX + +byIconStart, startY + +byIconStart, 0);
                    //绘制技能的锁定图标
                    if (((String) sHashtable.get(String.valueOf(1) + String.valueOf(i) + String.valueOf(3))).equals("1")) {
                        g.drawImage(this.imgArray[4], startX + Goods.byItemH - byIconStart - 15, startY + byIconStart, 0);
                    }
                }
            } else {
                //没有宠物的技能格子叉掉
                Tools.setColor(g, 0x000000);
                g.drawLine(startX + byIconStart, startY + byIconStart, startX + 29 + byIconStart, startY + 29 + byIconStart);
                g.drawLine(startX + byIconStart + 29, startY + byIconStart, startX + byIconStart, startY + 29 + byIconStart);
            }
        }

        //绘制宠物的描述或是技能的描述
        switch (this.bySelectIndex) {
            case 1:
                this.startY = this.iStartPointY;
                this.startX = Constant.UI_START_X + (Constant.DRAW_WIDTH - w >> 1);
                break;
            case 2:
                this.startY = this.iStartPointY + h + 5;
                this.startX = Constant.UI_START_X + (Constant.DRAW_WIDTH - w >> 1);
                break;
        }

        switch (this.byItemSelectIndex) {
            case 1:
                this.items.drawSelectStyle(g, startX + 7, startY + (h - Goods.byItemH >> 1));
                if (this.items.checkColumnHasGoods((short) (this.bySelectIndex - 1))) {
                    Tools.drawItemsPop(g, this.sItemTips, startX + 7, startY + (h - Goods.byItemH >> 1), this.shTipsW, this.shTipsH);
                }
                break;
            default:
                this.startX = this.byItemSelectIndex < 8 ? this.startX + 14 + Goods.byItemH + (Goods.byItemH - 1) * (this.byItemSelectIndex - 2) : this.startX + 14 + Goods.byItemH + (Goods.byItemH - 1) * (this.byItemSelectIndex - 8);
                this.startY = this.byItemSelectIndex < 8 ? this.startY + Constant.FONT_SMALL_HEIGHT + 20 : this.startY + Constant.FONT_SMALL_HEIGHT + 20 + Goods.byItemH - 1;
                this.items.drawSelectStyle(g, this.startX, this.startY);
                if (this.items.checkColumnHasGoods((short) (this.bySelectIndex - 1)) && sHashtable.containsKey(String.valueOf(this.bySelectIndex - 1) + String.valueOf(this.byItemSelectIndex - 2) + String.valueOf(1))) {
                    if (!bLock) {
                        Tools.drawItemsPop(g, this.sItemTips, this.startX, this.startY, this.shTipsW, this.shTipsH);
                    } else {
                        Goods.drawGoodsOperationMenu(g, sOpArray, (byte) 0, this.startX, this.startY);
                    }
                }
                break;
        }
        
        /////////////
        //Yujiang
        MainView.drawTouchRect(g, mPetComposeTouchRect);
    }

    /**
     * 清除宠物合成资源*
     */
    public void clearPetCompose() {
        this.imgArray = null;
        this.sArray = null;
        this.shPetState = null;
        this.items = null;
        this.sHashtable = null;
        this.sOpArray = null;
        this.sPetSkillNameDesc = null;
        this.sItemTips = null;

    }

    /**
     * 选择要合成的宠物
     * @param stateCode
     * @param packageGoods
     * @param shPos
     * @param byPetQuality  //品质
     * @param byPetGrowth  //成长
     * @param byPetSkillCiulmnNum //技能个数 
     */
    public void selectPetComposeItem(byte stateCode, Goods packageGoods, short shPos, byte byPetQuality, byte byPetGrowth, byte byPetSkillCiulmnNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        if (stateCode == 1) {
            //索引位置代表的意思:0:主宠的资质;1:主宠的成长;2:主宠的宠物槽数量;3:副宠的资质;4:副宠的成长;5:副宠的宠物槽数量;
            this.items.goodsClone((short) (this.bySelectIndex - 1), packageGoods, shPos);
            this.makeItemsTips(items, (short) (this.bySelectIndex - 1));
            this.shPetState[(this.bySelectIndex - 1) * 3 + 0] = byPetQuality;
            this.shPetState[(this.bySelectIndex - 1) * 3 + 1] = byPetGrowth;
            this.shPetState[(this.bySelectIndex - 1) * 3 + 2] = byPetSkillCiulmnNum;
            MainLogic.getInstance().uiPackage.closeBag();
        } else {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "选择合成宠物失败!");
        }
    }

    public void selectPetFromBg(Goods packageGoods, short shPos) {
        if ((this.items.checkColumnHasGoods((short) 0) && this.items.getGoodsColumnKey((short) 0) == packageGoods.getGoodsColumnKey(shPos)) || (this.items.checkColumnHasGoods((short) 1) && this.items.getGoodsColumnKey((short) 1) == packageGoods.getGoodsColumnKey(shPos))) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您已经选择过该宠物了!!");
            return;
        } else if (this.bySelectIndex == 2 && packageGoods.getGoodsBind(shPos) == 1) {
            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "已经绑定的宠物不可以作为合成副宠!!");
            return;
        }
        GameBean.b_WAIT_NET_MSG_BACK = true;
        GameBean.L_CMD_PET_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SELECT_PETCOMPOSE_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    /**
     * 设置宠物技能的hashtable
     * @param byPetIndex  //宠物的索引
     * @param bySkillIndex  //宠物技能槽的索引
     * @param iconID  //图片ID
     * @param sSkillName //技能名称
     * @param byLevel  //技能等级
     * @param bySkillLock //接那个是否锁定
     * @param desc  //技能描述
     */
    public void setSkillHashTable(byte byPetIndex, byte bySkillIndex, int iconID, String sSkillName, byte byLevel, byte bySkillLock, String desc) {
        MainLogic.getInstance().uiInterFace.pet.sHashtable.put(String.valueOf(byPetIndex) + String.valueOf(bySkillIndex) + String.valueOf(1), sSkillName + "，等级：" + byLevel + "。" + desc);
        MainLogic.getInstance().uiInterFace.pet.sHashtable.put(String.valueOf(byPetIndex) + String.valueOf(bySkillIndex) + String.valueOf(2), Goods.getGoodsIconFromID(iconID));
        MainLogic.getInstance().uiInterFace.pet.sHashtable.put(String.valueOf(byPetIndex) + String.valueOf(bySkillIndex) + String.valueOf(3), String.valueOf(bySkillLock));
    }

    /**
     * 移除hash中的技能数据
     */
    //成长率,当前潜能，总的潜能
    //this.iArray = new int[78];
    //0:宠物类型型(食草，食肉，杂食)
    //1:资质(0:平凡,2:优秀,1:杰出,3,完美)
    //2:成长(0-4:1星-5星)
    //3:当前宠物状态
    //4:当前经验值
    //5:最大经验值
    //6:快乐度
    //7:当前潜能
    //8:最大潜能
    //9:智力
    //10:精力
    //11:力量
    //12:灵敏
    //13宠物槽数量
    public void removeSkillHash(byte byPetIndex, byte bySkillColumnNum, byte skillIndex) {
        if (skillIndex == -1) {
            for (byte i = 0; i < bySkillColumnNum; i++) {
                if (this.sHashtable.containsKey(String.valueOf(byPetIndex) + String.valueOf(i) + String.valueOf(1))) {
                    this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(i) + String.valueOf(1));
                    this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(i) + String.valueOf(2));
                    this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(i) + String.valueOf(3));
                }
            }
        } else {
            if (this.sHashtable.containsKey(String.valueOf(byPetIndex) + String.valueOf(skillIndex) + String.valueOf(1))) {
                this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(skillIndex) + String.valueOf(1));
                this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(skillIndex) + String.valueOf(2));
                this.sHashtable.remove(String.valueOf(byPetIndex) + String.valueOf(skillIndex) + String.valueOf(3));
            }
        }

    }

    /**
     * 完成宠物的合成
     * @param stateCode 
     */
    public void completeCompose(byte stateCode, byte byPetDisapper, byte bySkillChangeNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物合成出错");
                break;
            case 1:
                if (byPetDisapper == 2) {
                    this.items.deleteGoods((short) 1);
                    //this.shPetState = new short[]{-1, -1, -1, -1, -1, -1};
                    //索引位置代表的意思:0:主宠的资质;1:主宠的成长;2:主宠的宠物槽数量;3:副宠的资质;4:副宠的成长;5:副宠的宠物槽数量;
                    this.removeSkillHash((byte) 1, (byte) this.shPetState[5], (byte) -1);
                    this.shPetState[5] = -1;
                    this.shPetState[4] = -1;
                    this.shPetState[3] = -1;
                }
                if (this.byItemSelectIndex == 1) {
                    this.makeItemsTips(items, (short) (this.bySelectIndex - 1));
                } else {
                    this.makeSkillTips((byte) (this.bySelectIndex - 1), (byte) (this.byItemSelectIndex - 1));
                }
                if (bySkillChangeNum == 0) {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物合成失败!");
                    return;
                } else {
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物合成成功!");
                }
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的副宠已经绑定了，不可以合成!");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "主宠或是副宠有特殊的技能，不可以合成!");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "主宠技能均已锁定且无空位,不能合成!");
                break;
            default:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物合成失败!");
                break;
        }
    }

    /**
     * 宠物使用物品
     */
    public void petUseItem(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "这件道具无法使!");
                break;
            case 1:
                if (MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.getInstance().uiPackage.shPos) > 1) {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().shStackNum[MainLogic.getInstance().uiPackage.shPos] -= 1;
                } else {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物使用智力书成功!");
//                GameBean.b_WAIT_NET_MSG_BACK = true;
//                this.bSetPetIndex = true;
                //MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 2:
                if (MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.getInstance().uiPackage.shPos) > 1) {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().shStackNum[MainLogic.getInstance().uiPackage.shPos] -= 1;
                } else {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物使用经验宝珠成功!!");
//                GameBean.b_WAIT_NET_MSG_BACK = true;
                //this.bSetPetIndex = true;
                //MainLogic.getInstance().uiPackage.closeBag();
                //MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "这件道具无法使用!");
                break;
            case 4:
                if (MainLogic.getInstance().uiPackage.getCurrentPackage().getGoodsStackNum(MainLogic.getInstance().uiPackage.shPos) > 1) {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().shStackNum[MainLogic.getInstance().uiPackage.shPos] -= 1;
                } else {
                    MainLogic.getInstance().uiPackage.getCurrentPackage().deleteGoods(MainLogic.getInstance().uiPackage.shPos);
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物使用技能书成功!!");

                //GameBean.b_WAIT_NET_MSG_BACK = true;
                //this.bSetPetIndex = true;
                //MainLogic.getInstance().uiPackage.closeBag();
                //MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 5:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的宠物等级不够!!");
                break;
            case 6:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物技能技能等级不够!!");
                break;
            case 7:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "当前宠物技能技能等级比学习等级高!!");
                break;
            case 8:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物技能槽数量已经达到最大!");
                break;
            case 9:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您的宠物没有这个技能!");
                break;
            default:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "这件道具无法使!");
                break;

        }
    }

    /**
     * 在宠物装备栏中喂食或是使用
     * this.byPetOperation = 1;// 改名
    this.byPetOperation = 2;// 休息
    this.byPetOperation = 3;// 守护
    this.byPetOperation = 4;// 喂养
    this.byPetOperation = 5;// 使用道具
    this.byPetOperation = 9;//卸下
    this.byPetOperation = 6;// 技能解锁
    this.byPetOperation = 7;// 技能锁定
    this.byPetOperation = 8;// 技能遗忘
     */
    public void petEquipSelectItem(Goods packageGoods, short shPos) {
        switch (this.byPetOperation) {
            case 4:
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_FEED, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 5:
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                GameBean.L_CMD_PET_SLOTKEY = this.items.getGoodsColumnKey((short) (this.byItemSelectIndex - 1));
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_PET_EQUIP_USE, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
            case 10:
                GameBean.b_WAIT_NET_MSG_BACK = true;
                GameBean.L_CMD_GOODS_SLOTKEY = packageGoods.getGoodsColumnKey(shPos);
                GameBean.I_CMD_COLUMN_INDEX = shPos;
                MainLogic.getInstance().send(Constant.MSG_NET_CMD_USE_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                break;
        }
    }

    private void makeItemsTips(Goods items, short shPos) {
        if (!items.checkColumnHasGoods(shPos)) {
            return;
        }
        short w = 0;
        this.shTipsW = (short) (Constant.FONT_SMALL.stringWidth(items.getGoodsAlias(shPos)));
        this.sItemTips = "<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(items.getGoodsColor(shPos))) + items.getGoodsAlias(shPos) + ">";
        this.sItemTips += "|等级：" + items.getGoodsLevel(shPos);
        w = (short) (Constant.FONT_SMALL.stringWidth("|等级：" + items.getGoodsLevel(shPos)));
        this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        this.shTipsH = (short) ((Constant.FONT_SMALL_HEIGHT << 1) + 10);
        if (this.shTipsW < 40) {
            this.shTipsW = 40;
        }
        this.shTipsW += 10;
    }

    private void makeSkillTips(byte petIndex, byte bySkillIndex) {
        if (sHashtable.containsKey(String.valueOf(petIndex) + String.valueOf(bySkillIndex) + String.valueOf(1))) {
            this.shTipsH = (short) ((Constant.FONT_SMALL_HEIGHT << 1) + 10);
            this.sItemTips = this.sPetSkillNameDesc[petIndex * 12 + bySkillIndex];
            if (this.sItemTips == null) {
                return;
            }
            int pos = this.sItemTips.indexOf('|');
            int lastLength = this.sItemTips.length() - pos;
            this.shTipsW = (short) ((pos >= lastLength ? pos : lastLength) * Constant.FONT_CHAR_WIDTH + 10);

        }
    }
    
    //////////////////////////////////////

    public static int BOX_SIZE = 40;
    public static int BOX_SPACE_Y = 10;
    
    public static int[][] mPetEquipOperateRect;
    public static int[][] mPetEquipTouchRect = new int[][]{
    	//
    	{33,50,BOX_SIZE,BOX_SIZE},
    	{33 + BOX_SIZE + BOX_SPACE_Y,50,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 2,50,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 3,50,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 4,50,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 5,50,BOX_SIZE,BOX_SIZE},
    	//
    	{33,267,BOX_SIZE,BOX_SIZE},
    	{33 + BOX_SIZE + BOX_SPACE_Y,267,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 2,267,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 3,267,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 4,267,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 5,267,BOX_SIZE,BOX_SIZE},
    	
    	{33,313,BOX_SIZE,BOX_SIZE},
    	{33 + BOX_SIZE + BOX_SPACE_Y,313,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 2,313,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 3,313,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 4,313,BOX_SIZE,BOX_SIZE},
    	{33 + (BOX_SIZE + BOX_SPACE_Y) * 5,313,BOX_SIZE,BOX_SIZE},
    	
    	
    };
    public void checkTouchPetEquip(int x, int y)
    {
    	if(bLock)
    	{
    		mPetEquipOperateRect = Tools.getPopMenuTouch(sOpArray, (byte) 1,
					Constant.FONT_SMALL.stringWidth("查看") + 2,
					Constant.FONT_SMALL_HEIGHT + 1, 0x000000,
					0xFFFFFF, 0x00CCFF, this.byMenuIndex,  Constant.UI_START_X + 33 + 50 * (this.byItemSelectIndex - 1), Constant.UI_START_Y + 49);
    		
    		
	    	int touched = MainCanvas.checkTouch(x, y, mPetEquipOperateRect);
	    	if(touched >= 0)
	    	{
	    		byMenuIndex = (byte) touched;
	    		MainCanvas.pressFire();
	    	}
	    	else
	    	{
	    		MainCanvas.pressBack();
	    	}
    		
    		return;
    	}
    	int touched = MainCanvas.checkTouch(x, y, mPetEquipTouchRect);
		 if(touched >= 0)
		 {
			 if(byUiState == 0)
			 {
				 if(touched < 6)
				 {
					 if(bySelectIndex == 1 &&  byItemSelectIndex == (byte) (touched + 1))
					 {
						 MainCanvas.pressFire();
					 }
					 else
					 {
						 bySelectIndex = 1;
						 bySubSelectIndex = 1;
						 byItemSelectIndex =(byte) (touched + 1);			 
						 this.setPetString((byte) (this.byItemSelectIndex - 1));
					 }
					 
				 }
				 else if(touched >= 6 && touched < 12)
				 {
					 if(bySelectIndex == 2 &&  bySubSelectIndex == (byte) (touched + 1 - 6))
					 {
						 MainCanvas.pressFire();
					 }
					 else
					 {
						 bySelectIndex = 2;
						 bySubSelectIndex = (byte) (touched + 1 - 6);
					 }
				 }
				 else if(touched >= 12 && touched < 18) 
				 {
					 if(bySelectIndex == 3 &&  bySubSelectIndex == (byte) (touched + 1 - 6))
					 {
						 MainCanvas.pressFire();
					 }
					 else
					 {
						 bySelectIndex = 3;
						 bySubSelectIndex = (byte) (touched + 1 - 6);
					 }
				 }
				 setRollText();
			 }
		 }
		 else
		 {
			 MainCanvas.checkSoftKey();
		 }
    }
    
    public static int[][] mPetPowerStrengthTouchRect = new int[][]{
    	{25,60,BOX_SIZE,BOX_SIZE},
    	{25,130,BOX_SIZE,BOX_SIZE},
    };
    public void checkTouchPetPowerStrength(int x, int y)
    {
    	int touched = MainCanvas.checkTouch(x, y, mPetPowerStrengthTouchRect);
		 if(touched >= 0)
		 {
			 
			 if(byItemSelectIndex == (byte) (touched + 1))
			 {
				 MainCanvas.pressFire();
			 }
			 else
			 {
				 byItemSelectIndex = (byte) (touched + 1);
			 }
		 }
		 else
		 {
			 MainCanvas.checkSoftKey();
		 }
    }
    
    public static int[][] mPetComposeTouchRect = new int[][]{
    	//主位
    	{33,92,BOX_SIZE,BOX_SIZE},
    	
    	{80,90,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE,90,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 2,90,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 3,90,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 4,90,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 5,90,BOX_SIZE,BOX_SIZE},
    	
    	{80,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 2,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 3,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 4,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 5,90 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	
    	//副位
    	{33,216,BOX_SIZE,BOX_SIZE},
    	
    	{80,214,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE,214,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 2,214,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 3,214,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 4,214,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 5,214,BOX_SIZE,BOX_SIZE},
    	
    	{80,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 2,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 3,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 4,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	{80 + BOX_SIZE * 5,214 + BOX_SIZE,BOX_SIZE,BOX_SIZE},
    	
    };
    public void checkTouchPetCompose(int x, int y)
    {
    	System.out.println("bySelectIndex = " +bySelectIndex);
    	System.out.println("byItemSelectIndex = " + byItemSelectIndex);
    	int touched = MainCanvas.checkTouch(x, y, mPetComposeTouchRect);
		 if(touched >= 0)
		 {
			 if(touched < 13)
			 {
				
				 if(bySelectIndex == 1 && byItemSelectIndex == (byte) (touched+1))
				 {
					 MainCanvas.pressFire();
				 }
				 else
				 {
					 bySelectIndex = 1;
					 byItemSelectIndex = (byte) (touched+1);
				 }
			 }
			 else
			 {
				
				 if(bySelectIndex == 2 && byItemSelectIndex == (byte) (touched+1 - 13))
				 {
					 MainCanvas.pressFire();
				 }
				 else
				 {
					 bySelectIndex = 2;
					 byItemSelectIndex = (byte) (touched+1 - 13);
				 }
			 }
			 
			 if (this.byItemSelectIndex == 1) {
                 this.makeItemsTips(items, (short) (this.bySelectIndex == 1 ? 0 : 1));
             } else {
                 this.makeSkillTips((byte) (this.bySelectIndex - 1), (byte) (this.byItemSelectIndex - 2));
             }
		 }
		 else
		 {
			 MainCanvas.checkSoftKey();
		 }
    }
}
